class IsometricGamePlayerController extends GamePlayerController;
var bool bPawnNearDestination;
var float DistanceRemaining; 
var zombiePawn Followers[6];
var bool shift;
var int type;
enum EMouseEvent
{
  LeftMouseButton,
  RightMouseButton,
  MiddleMouseButton,
  ScrollWheelUp,
  ScrollWheelDown,
};

simulated event PreBeginPlay(){

//launch menu
//assgin type
}
simulated event PostBeginPlay(){
if(type==0){
               SpawnHumanPawn(Vect(0,0,0));
               }
if(type==1){
               SpawnZombiePawn(Vect(0,0,0));
               }
}
function SpawnHumanPawn(Vector spawnspot){
			local Pawn ResultPawn;
           Possess(spawn(class'myPawn', , ,  spawnspot, , ,), false);
           Tag='human';
           `Log("Human Spawned");
}

function vector SpawnPoint(int type){
  local vector SpawnPoint;
  SpawnPoint=vect(0,0,0);
//arrays of potential spawn points for humans and zombies
//random integer generator to pick a spawn point and check it's not occupied
//assign SpawnPoint
return SpawnPoint;
}
function SpawnZombiePawn(Vector spawnspot){
local Pawn ResultPawn;
           Possess(spawn(class'myPawn', , ,  spawnspot, , ,), false);
           Tag='zombie';
           `Log("Zombie Spawned");
           if(ResultPawn != none)
	{
		PlayerSpawned(spawnspot);
	}
}
function PlayerSpawned(Vector StartLocation)
{
`Log("Follower is alive");
Followers[0] = Spawn(class'zombiePawn',,, startlocation - vect(100,100,0),);
Followers[1] = Spawn(class'zombiePawn',,, startlocation - vect(200,100,0), );
Followers[2] = Spawn(class'zombiePawn',,, startlocation - vect(100,200,0), );
Followers[3] = Spawn(class'zombiePawn',,, startlocation - vect(200,200,0), );
Followers[4] = Spawn(class'zombiePawn',,, startlocation - vect(300,200,0), );
}
 exec function NextWeapon()
    {
    PlayerCamera.FreeCamDistance += 64;
    }

    exec function PrevWeapon()
    {
    PlayerCamera.FreeCamDistance -= 64;
    }



// Handle mouse inputs
function HandleMouseInput(EMouseEvent MouseEvent, EInputEvent InputEvent)
{
  local FinalHUD yarg;
  local MyPlayerInput mine;

  // Type cast to get our HUD
  yarg = FinalHUD(myHUD);
  mine = MyPlayerInput(PlayerInput);
  if (yarg != None)
  {
    // Detect what kind of input this is
    if (InputEvent == IE_Pressed)
    {
      // Handle pressed event
      switch (MouseEvent)
      {
        case LeftMouseButton:
		yarg.startPos.X = mine.MousePosition.X;
		yarg.startPos.Y = mine.MousePosition.Y;
	  yarg.PendingLeftPressed = true;
	  break;

	case RightMouseButton:
	  yarg.PendingRightPressed = true;
	  break;

	case MiddleMouseButton:
	  yarg.PendingMiddlePressed = true;
	  break;

	default:
	  break;
      }
    }
    else if (InputEvent == IE_Released)
    {
      // Handle released event
      switch (MouseEvent)
      {
        case LeftMouseButton:
	  yarg.PendingLeftReleased = true;
	  	  yarg.PendingLeftPressed = false;
	  break;

	case RightMouseButton:
	  yarg.PendingRightReleased = true;
	  break;

	case MiddleMouseButton:
	  yarg.PendingMiddleReleased = true;
	  break;

	default:
	  break;
      }
    }
  }
}

// Hook used for the left and right mouse button when pressed
exec function StartFire(optional byte FireModeNum)
{
  HandleMouseInput((FireModeNum == 0) ? LeftMouseButton : RightMouseButton, IE_Pressed);
  Super.StartFire(FireModeNum);
}

// Hook used for the left and right mouse button when released
exec function StopFire(optional byte FireModeNum)
{
  HandleMouseInput((FireModeNum == 0) ? LeftMouseButton : RightMouseButton, IE_Released);
  Super.StopFire(FireModeNum);
}

// Called when the middle mouse button is pressed
exec function MiddleMousePressed()
{
  HandleMouseInput(MiddleMouseButton, IE_Pressed);
}

// Called when the middle mouse button is released
exec function MiddleMouseReleased()
{
  HandleMouseInput(MiddleMouseButton, IE_Released);
}

// Called when the middle mouse wheel is scrolled up
exec function MiddleMouseScrollUp()
{
  HandleMouseInput(ScrollWheelUp, IE_Pressed);
}

// Called when the middle mouse wheel is scrolled down
exec function MiddleMouseScrollDown()
{
  HandleMouseInput(ScrollWheelDown, IE_Pressed);
}

// Null this function

// Override this state because StartFire isn't called globally when in this function
auto state PlayerWaiting
{
  exec function StartFire(optional byte FireModeNum)
  {
    Global.StartFire(FireModeNum);
  }
}
exec function toggleshift(){
	FinalHUD(myHUD).shift = !FinalHUD(myHUD).shift;
}
function UpdateRotation( float DeltaTime )
{
   local Rotator   DeltaRot, ViewRotation;

   ViewRotation = Rotation;

   // Calculate Delta to be applied on ViewRotation
   DeltaRot.Yaw = Pawn.Rotation.Yaw;
   DeltaRot.Pitch   = PlayerInput.aLookUp;

   ProcessViewRotation( DeltaTime, ViewRotation, DeltaRot );
   SetRotation(ViewRotation);
}

DefaultProperties
{
	CameraClass=class'IsometricCamera'
  // Set the input class to the mouse interface player input
  InputClass=class'MyPlayerInput' 
  Name="Default__MyController"


}
